<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko">
<head>
	<title>jsString Test Suite</title>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<link type="text/css" rel="stylesheet" href="jsspec/JSSpec.css" />
	<script type="text/javascript" src="jsspec/diff_match_patch.js"></script>
	<script type="text/javascript" src="jsspec/JSSpec.js"></script>
	<script type="text/javascript" src="../jsString.js"></script>
</head>
<body>
<script type="text/javascript" language="javascript">// <![CDATA[
describe("Simple", {
	
	
	'should leave "a b c" as "a b c"': function() {
		var b = "bee";
		value_of( $s("a b c".$s()) ).should_be("a b c");
	},
	
	'should convert "a $b c" into "a bee c"': function() {
		var b = "bee";
		value_of( $s("a $b c".$s()) ).should_be("a bee c");
	},
	
	'should convert "a $b c $b" into "a bee c bee"': function() {
		var b = "bee";
		value_of( $s("a $b c $b".$s()) ).should_be("a bee c bee");
	},
	
	'should escape "a \\\\$b c d" and return "a $b c d"': function() {
		var b = "bee";
		value_of( $s("a \\$b c d".$s()) ).should_be("a $b c d");
	},
	
	'should convert "a $b c $d" into "a bee c d"': function() {
		var b = "bee";
		var dee = "d";
		value_of( $s("a $b c $dee".$s()) ).should_be("a bee c d");
	}
});

describe("Complex", {
	
	'should convert "a $b.anyvar c $dee" into "a bee c d"': function() {
		var b = {anyvar:"bee"};
		var dee = "d";
		value_of( $s("a $b.anyvar c $dee".$s()) ).should_be("a bee c d");
	},
	
	
	'should convert "a $b[0] c $dee[1]" into "a bee c d"': function() {
		var b = ["bee"];
		var dee = ["", "d"];
		value_of( $s("a $b[0] c $dee[1]".$s()) ).should_be("a bee c d");
	},
	
	'should convert "a $b[\'anyvar\'] c $dee[\'anyvar\']" into "a bee c d"': function() {
		var b = {anyvar:"bee"};
		var dee = {anyvar:"d"};
		value_of( $s("a $b['anyvar'] c $dee['anyvar']".$s()) ).should_be("a bee c d");
	},
	
	'should convert \'a $b["anyvar"] c $dee["anyvar"]\' into "a bee c d"': function() {
		var b = {anyvar:"bee"};
		var dee = {anyvar:"d"};
		value_of( $s('a $b["anyvar"] c $dee["anyvar"]'.$s()) ).should_be("a bee c d");
	},
	
	'should convert "a $b[\\"anyvar\\"] c d" into "a bee c d"': function() {
		var b = {anyvar:"bee"};
		var dee = {anyvar:"d"};
		value_of( $s("a $b[\"anyvar\"] c d".$s()) ).should_be("a bee c d");
	},
	
	'should convert "a $b[\'anyvar\'] c $dee[\'anyvar\']" into "a bee c d"': function() {
		var b = {anyvar:"bee"};
		var dee = {anyvar:"d"};
		value_of( $s("a $b['anyvar'] c $dee['anyvar']".$s()) ).should_be("a bee c d");
	},
	
	'should convert "a $b.anyvar[0] c $dee.anyvar[\'nestedvar\']" into "a bee c d"': function() {
		var b = {anyvar:["bee"]};
		var dee = {anyvar:{nestedvar:"d"}};
		value_of( $s("a $b.anyvar[0] c $dee.anyvar['nestedvar']".$s()) ).should_be("a bee c d");
	},
	
	'should convert "a $b.anyvar.nestedvar c $dee[\'anyvar\'][\'nestedvar\']" into "a bee c d"': function() {
		var b = {anyvar:{nestedvar:"bee"}};
		var dee = {anyvar:{nestedvar:"d"}};
		value_of( $s("a $b.anyvar.nestedvar c $dee['anyvar']['nestedvar']".$s()) ).should_be("a bee c d");
	},
	
	'should convert "a $b.anyvar.nestedvar c $dee[\'anyvar\'][\'nestedvar\']" into "a bee c d"': function() {
		var b = {anyvar:{nestedvar:["bee"]}};
		var dee = {anyvar:["d"]};
		value_of( $s("a $b.anyvar.nestedvar[0] c $dee['anyvar'][0]".$s()) ).should_be("a bee c d");
	},
	
	'should convert "a \'$b.anyvar.nestedvar\' c $dee[\'anyvar\'][\'nestedvar\']" into "a \'bee\' c d"': function() {
		var b = {anyvar:{nestedvar:["bee"]}};
		var dee = {anyvar:["d"]};
		value_of( $s("a '$b.anyvar.nestedvar[0]' c $dee['anyvar'][0]".$s()) ).should_be("a 'bee' c d");
	}
	
});

// ]]></script>
</body>
</html>